/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * StandardPanel.java
 *
 * Created on 2011-4-22, 12:49:34
 */

package com.iduxs.collect.frame.collect;

import com.iduxs.collect.utils.Utility;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class StandardPanel extends javax.swing.JPanel {

    private CollectModePanel collectModePanel;
    private CollectActionPanel collectActionPanel;

    /** Creates new form StandardPanel */
    public StandardPanel() {
        initComponents();
        init();
    }

    private void init() {
        try {
            collectModePanel = new CollectModePanel();
            mainTabs.add("采集模式", collectModePanel);
            CollectMode cm = new CollectMode();
            Utility.readXMLFile("CollectMode.xml", cm);
            collectModePanel.setCollectMode(cm);

            collectActionPanel = new CollectActionPanel();
            mainTabs.add("采集动作", collectActionPanel);
            CollectAction ca = new CollectAction();
            Utility.readXMLFile("CollectAction.xml", ca);
            collectActionPanel.setCollectAction(ca);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        mainTabs = new javax.swing.JTabbedPane();

        jButton2.setFont(new java.awt.Font("宋体", 0, 12)); // NOI18N
        jButton2.setText("开始");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setFont(new java.awt.Font("宋体", 0, 12)); // NOI18N
        jButton3.setText("停止");

        jButton4.setFont(new java.awt.Font("宋体", 0, 12)); // NOI18N
        jButton4.setText("采集方案");

        mainTabs.setPreferredSize(new java.awt.Dimension(630, 394));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(414, Short.MAX_VALUE)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton4)
                .addGap(21, 21, 21))
            .addComponent(mainTabs, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 652, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(mainTabs, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton3)
                    .addComponent(jButton4))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        try {
            Utility.writeXMLFile("CollectMode.xml", collectModePanel.getCollectMode());
            Utility.writeXMLFile("CollectAction.xml", collectActionPanel.getCollectAction());
        } catch (Exception ex) {
            Logger.getLogger(StandardPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton2ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JTabbedPane mainTabs;
    // End of variables declaration//GEN-END:variables

}
